<template>
  <div class="tab-pannel">
    <div :class="['tab-title', { active: isShow }]" @click="tabHandClick(name, label)">
      {{ label }}
    </div>
    <div class="tab-content" v-show="isShow">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    label: String,
    name: String
  },
  inject: ['itemObj'],

  methods: {
    tabHandClick() {
      console.log(this.name)
      this.itemObj.name = this.name
    }
  },
  computed: {
    isShow() {
      return this.itemObj.name === this.name
    }
  },
  mounted() {
    this.itemObj.name = this.$parent.value
  }
}
</script>
